package org.example.cake.controller;

import org.example.cake.common.Rep;
import org.example.cake.entity.Orderpayinfo;
import org.example.cake.entity.Paycakeid;
import org.example.cake.entity.Userdiscount;
import org.example.cake.service.BuycarService;
import org.example.cake.service.OrdercakeService;
import org.example.cake.service.PaycakeidSercice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/paycake")
public class PaycakeidController {
    @Autowired
    private PaycakeidSercice paycakeidSercice;
    @Autowired
    private OrdercakeService ordercakeService;
    @Autowired
    BuycarService buycarService;
    /**
     * 把订单里的蛋糕添加到这个表中
     * @Date 2025-08-01 谭丽娜
     * @param paycakeid
     * @return
     */
    @PostMapping("/loadcakeidapi")
    public Rep  loadcakeidapi(@RequestBody Paycakeid paycakeid) {
        System.out.println("paycakeid = " + paycakeid);
        Integer res=paycakeidSercice.insertAddcakeid(paycakeid);
        //清楚购物车
        buycarService.delBuycar(paycakeid.getBuycarid());
        //查询订单总数
        //Integer count=paycakeidSercice.selectpaycount(paycakeid);
        //修改订单总数
        //ordercakeService.updateordercount(count,paycakeid.getPayid());
        return new Rep().addData("res",res);
    }

}
